package com.xdf.whiteaccount.service;

import java.util.List;
import java.util.Optional;
import com.xdf.whiteaccount.entity.Defectivegoods;
import com.xdf.whiteaccount.utils.Example;
import com.xdf.whiteaccount.utils.BusinessException;

/**
 * 版本号：20240401
 * @Description : 服务层接口，注意自定义代码写在最后，不要插在中间
 * @Author : chanchaw
 * @Date : 2025-9-5 14:54:28
 */
public interface DefectivegoodsService {
    Defectivegoods insert(Defectivegoods record);
    Defectivegoods insertSelective(Defectivegoods record);
    List<Defectivegoods> multiInsert(List<Defectivegoods> list);
    int updateByPrimaryKey(Defectivegoods record);
    int updateByPrimaryKeySelective(Defectivegoods record);
    // 根据主键删除
    int deleteByPrimaryKey(Integer B_itemId);
    // 根据主键查询
    Defectivegoods selectByPrimaryKey(Integer B_itemId);
    List<Defectivegoods> selectAll();
    Defectivegoods save(Defectivegoods record);
    List<Defectivegoods> multiSave(List<Defectivegoods> list);
    Defectivegoods selectBySid(String sid);
    Boolean exists(String sid);
    //================= 下面是默认方法 ==================
    default void checkEntityNotNull(Defectivegoods record){// 返回true表示合法，可继续
        if(record == null) throw new BusinessException("无法保存空数据！");
    }

    default void checkSidNotEmpty(Defectivegoods record){// 返回true表示合法，可继续
//        checkEntityNotNull(record);
//        String sid = Optional.ofNullable(record.getSid()).orElse("");
//        if(sid.length() == 0) throw new BusinessException("编号不可为空！");
    }

    default Defectivegoods fullFill(Defectivegoods record){
        return record;
    }

    default void doBeforeInsert(Defectivegoods record){}
    default void doAfterInsert(Defectivegoods record){}
    List<Defectivegoods> selectByExample(Example<Defectivegoods> example);
    default void check4Insert(Defectivegoods record){
//        checkSidNotEmpty(record);
//        if(exists(record.getSid())) throw new BusinessException("编号" + record.getSid() + "已经存在，请更换后再次保存！");
    }
    //=================以上是自动生成的代码，自定义代码请写在下面==================
    List<Defectivegoods> selectByParam(Defectivegoods record);
}